<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateOrdersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('orders', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('userid')->comment('用户ID');
            $table->string('nickname')->comment('用户昵称');
            $table->integer('shopid')->comment('商家id');
            $table->string('shopname', 20)->comment('商家名称');
            $table->string('shoplogo')->comment('商家logo');
            $table->string('ordernumber')->unique()->comment('订单号');
            $table->decimal('orderamount', 16,2)->comment('订单金额');
            $table->decimal('shopamount', 16,2)->comment('商家实收金额');
            $table->decimal('actualamount',16,2)->comment('实付金额');
            $table->decimal('redenvelopeamount', 16,2)->default(0)->comment('红包金额');
            $table->integer('redenvelopeid')->unique()->nullable()->comment('红包id');
            $table->decimal('fee', 16,2)->default(0)->comment('手续费');
            $table->integer('commentscore')->default(0)->comment('评论分数');
            $table->tinyInteger('commentstatus')->default(0)->comment('评论状态');
            $table->tinyInteger('status')->default(0)->comment('是否结算');
            $table->integer('shopuserid')->default(0)->comment('商家收款人ID');
            $table->tinyInteger('accountstatus')->default(0)->comment('是否结款');
            $table->dateTime('accounttime')->default(0)->comment('结款时间');
            $table->decimal('accountamount',16,2)->default(0)->comment('结款金额');
            $table->tinyInteger('refundstatus')->default(0)->comment('退款状态');
            $table->integer('adminid')->comment('后台操作人id');
            $table->decimal('startbalance',16,2)->comment('交易前余额');
            $table->decimal('lastbalance',16,2)->comment('交易后余额');
            $table->integer('cityid', 11)->default(1)->comment('城市id');
            $table->string('path', 32)->default('')->comment('买单方式');
            $table->decimal('hqamount', 16, 2)->default(0.00)->comment('总部红包金额');
            $table->decimal('agentamount', 16, 2)->default(0.00)->comment('总部红包金额');
            $table->decimal('bonus', 16, 2)->default(0.00)->comment('领取红包金额');
            $table->integer('bonusid')->default(0)->comment('领取红包id');
            $table->integer('maintainerid')->default(0)->comment('维护人id');
            $table->string('info', 256)->nullable()->comment('预留字段');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('orders');
    }
}
